#!/bin/sh
bundle_dir=$(dirname "$0")/../Resources
case "$(/usr/bin/uname -m)" in
  arm64) runtime=arm64 ;;
  x86_64) runtime=x64 ;;
  *) /usr/bin/osascript -e 'display alert "TERN DJ requires an Intel or Apple silicon Mac."'; exit 1 ;;
esac
if ! "$bundle_dir/runtime/$runtime/node" --version >/dev/null 2>&1; then
  /usr/bin/osascript -e 'display alert "TERN DJ could not start on this Mac." message "Keep the app together when unzipping it. Contact Aren if the issue continues."'
  exit 1
fi
/usr/bin/nohup "$bundle_dir/runtime/$runtime/node" "$bundle_dir/app.cjs" </dev/null >/dev/null 2>&1 &
